<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>sse</title>
</head>
<body>
<div id="sse"></div>
<script>
    let eventSource = new EventSource("/flux/stream");
    eventSource.onmessage = function (event) {
        console.log("搜到消息 " + event);
        document.getElementById("sse").innerHTML = event.data;
    };


    // eventSource.addEventListener("foo", function (event) {
    //     console.log("搜到消息 " + event);
    //     document.getElementById("sse").innerHTML = event.data;
    // });

    eventSource.addEventListener("end", function (event) {
        console.log("搜到消息 " + event);
        document.getElementById("sse").innerHTML = event.data;
        eventSource.close();
    });

</script>
</body>
</html>